package com.xx.job.controller.system;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xx.job.common.PageResult;
import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysFileInfo;
import com.xx.job.service.system.SysFileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysFileInfoController extends BaseController {

    @Autowired
    private SysFileInfoService sysFileInfoService;

    @RequestMapping("/sysfileinfoList")
    public Result sysfileinfoList(PageDTO pageDTO, SysFileInfo sysFileInfo){
        IPage<SysFileInfo> sysfileinfoIPage;
        sysfileinfoIPage = sysFileInfoService.selectPage(pageDTO, sysFileInfo);
        return Result.success(new PageResult(sysfileinfoIPage));
    }

    @PostMapping("/sysfileinfo")
    public Result addFileInfo(@RequestBody SysFileInfo sysFileInfo){
        return Result.success(sysFileInfoService.add(sysFileInfo));
    }

    @DeleteMapping("/sysfileinfo/{id}")
    public Result deleteFileInfo(@PathVariable Long id){
        return Result.success(sysFileInfoService.delete(id));
    }

    @PutMapping("/sysfileinfo")
    public Result updateFileInfo(@RequestBody SysFileInfo sysFileInfo){
        return Result.success(sysFileInfoService.update(sysFileInfo));
    }

    @GetMapping("/sysfileinfo/{id}")
    public Result selectFileInfo(@PathVariable Long id){
        return Result.success(sysFileInfoService.select(id));
    }
}

